<template>
  <div class="more-container">
    <!-- 提示框 -->
    <warn class="warn" :borderColor='"#91d5ff"' :content='`您好！您的驾校信息完成度：${baseInfo.rate}。请及时完善班型信息、训练场信息、考场信息。`' :bgc='"#e6f7ff"'
      :iconcolo="'#1890ff'"></warn>
    <!-- 内容区域 -->
    <div class="content-main" v-if="true">
      <div class="drivingschoolimg">
        <img :src="baseInfo.head_img" alt="">
      </div>
      <div class="drivingcontent" v-if="isData">
        <div id="drivingcontent">
          <!-- 驾校名字 -->
          <div class="d-name">
            <h3>{{baseInfo.short_title}}</h3>
          </div>
          <!-- 排名 -->
          <div class="d-pm">
            <span class="pmclass">{{baseInfo.sort}}</span>
            <span class="tagclass">学员{{baseInfo.student}}人</span>
            <span class="tagclass">评分{{baseInfo.score}}分</span>
          </div>
          <!-- 列表区域 -->
          <div class="d-list">
            <ul>
              <li>
                <div class="d-list-title">驾校地址：</div>
                <div class="d-list-content">{{baseInfo.address}}</div>
              </li>
              <li>
                <div class="d-list-title">基础设施：</div>
                <div class="d-list-content">
                  <ul class="baseIcon">
                    <li v-for="(item,index) in facilityOption" :key='index'>
                      <img :src="item.alias" :class="item.ison?'on':''">
                      <span>{{item.title}}</span>
                    </li>
                  </ul>
                </div>
              </li>
              <li v-if="false">
                <div class="d-list-title">驾校标签：</div>
                <div class="d-list-content">
                  <ul class="d-icon">
                    <li v-for="(item,index) in 7" :key='index' @click="cTag">
                      <span>大</span>
                      <span>规模大</span>
                    </li>
                  </ul>
                </div>
              </li>

              <li>
                <div class="d-list-title">考试资质：</div>
                <div class="d-list-content" v-if="baseInfo.schoolBase">{{baseInfo.schoolBase.qualifications.title.join('、')}}</div>
                <div class="d-list-content" v-else>-</div>
              </li>
              <li>
                <div class="d-list-title">附加服务：</div>
                <div class="d-list-content" v-if="baseInfo.schoolBase">{{baseInfo.schoolBase.service.title.join('、')}}</div>
                <div class="d-list-content" v-else>-</div>
              </li>
              <li>
                <div class="d-list-title">班型信息：</div>
                <div class="d-list-content">已设置{{baseInfo.course}}个班型 <el-link type="primary" :underline='false' style="margin-left:5px;"
                    @click="classtype">前往设置</el-link>
                </div>
              </li>
              <li>
                <div class="d-list-title">场地信息：</div>
                <div class="d-list-content">已设置{{baseInfo.enrollPoint}}个<el-link type="primary" @click='gobmd'>报名点</el-link>、{{baseInfo.trainPlace}}个<el-link
                    type="primary" @click='goxlc'>训练场</el-link>、{{baseInfo.examPlace}}个<el-link type="primary" @click='gokc'>考场</el-link>
                </div>
              </li>
            </ul>
          </div>

        </div>
      </div>
      <div class="editbtn">
        <el-button plain @click="baseinfoedit">编辑</el-button>
      </div>
      <editform v-if="isshowEdit" :isshowDialog='isshowEdit' @closeDialog='closeDialog' @confirmbtn='confirmbtn'></editform>
    </div>

  </div>
</template>

<script>
  //提示组件
  import warn from '@/components/warn/warn'
  //编辑弹窗
  import editform from './component/editform'
  //api
  import {
    getBaseInfo
  } from '@/api/school'
  import {
    getCOption
  } from '@/api/common'
  import {
    getSessionStorage
  } from '@/utils/accessToken'
  export default {
    data() {
      return {
        //数据是否加载成功
        isData: false,
        //是否需要显示编辑弹窗
        isshowEdit: false,
        //基础信息
        baseInfo: {},
        //基础设施图标
        facilityOption: []
      }
    },
    components: {
      warn,
      editform
    },
    methods: {
      //获取固定选项数据
      async getCarOption() {
        let data = await getCOption()
        if (data.code == '0000') {
          //存入sessionStorage
          window.sessionStorage.setItem('Options', JSON.stringify(data.data))
        }
      },
      confirmbtn() {
        this.isshowEdit = false
        //刷新数据
        this.getCarOption()
        //刷新数据
        this.getBaseInfoData()
        //基础设施选项
        this.facilityOption = getSessionStorage('Options')[20]

      },
      //前往设置班型
      classtype() {
        this.$router.push({
          path: '/calsstypemanage/classtype'
        })
      },
      //去训练场
      goxlc() {
        this.$router.push({
          path: '/organizationmanage/training'
        })
      },
      //去报名点
      gobmd() {
        this.$router.push({
          path: '/organizationmanage/assigns'
        })
      },
      //前往设置考场
      gokc() {
        this.$router.push({
          path: '/organizationmanage/examination'
        })
      },
      //点亮标签
      clickTag() {
        this.$message({
          message: '最多选择三个标签！',
          type: 'success'
        });
      },
      cTag() {

      },
      //编辑
      baseinfoedit() {
        this.isshowEdit = true
      },
      //关闭弹窗
      closeDialog() {
        this.isshowEdit = false
      },
      //获取基础信息
      async getBaseInfoData() {
        let data = await getBaseInfo()
        this.baseInfo = data.data
        //    return

        if (data.data.schoolBase) {
          this.facilityOption.forEach((items, index) => {
            data.data.schoolBase.facilities.value.forEach((item, index) => {
              if (items.id == item) {
                this.$set(items, 'ison', true)
              }
            })
          })
        }
        //数据加载成功
        this.isData = true
      }

    },
    mounted() {
      //获取基础信息
      this.getBaseInfoData()
      //基础设施选项
      this.facilityOption = getSessionStorage('Options')[20]
    }
  }
</script>

<style scoped lang='scss'>

</style>
